package com.mxw.算法之美.a1数组;

public class 区间和 {
    public static void preSum(int[] args) {

        int length = args.length;
        int[] preSum = new int[length];

        int presum = 0;
        for (int i = 0; i < length; i++) {
            presum += args[i];
            preSum[i] = presum;
        }


        int a = 1;
        int b = 2;

        int sum;
        if (a == 0) {
            sum = preSum[b];
        } else {
            sum = preSum[b] - preSum[a - 1];
        }
        System.out.println(sum);

    }
}
